package com.cjq.service.Impl;

import com.cjq.dao.BaseAdminDao;
import com.cjq.dao.Impl.AdminDaoMysql;
import com.cjq.service.AdminService;

import java.util.Date;

public class AdminServiceImpl implements AdminService {
   private AdminDaoMysql dao =  new AdminDaoMysql();

    //修改登录的时间和id
    @Override
    public void updateLoginTimeAndIP(String username, Date date, String ip) {
        if (username.startsWith("admi")){

            dao.updateLoginTime(username,date,ip);
        }else{

            dao.updateLoginTimeForCoutier(username,date,ip);
        }

    }

    //验证登录账号密码
    @Override
    public boolean login(String username, String password) {
        if (username.startsWith("admi")){
            System.out.println("管理员");
            return dao.login(username, password);
        }else{
            System.out.println("快递员");
            return dao.loginForCoutier(username, password);
        }
    }

    @Override
    public String sessionPhoneCourier(String username, String password) {

        if (username.startsWith("admi")){
            return "管理员录入";
        }else{
            return dao.sessionPhoneCourier(username, password);
        }

    }
}
